<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class Department extends Model
{
    use  HasDateTimeFormatter, SoftDeletes;

    protected $fillable = ['ding_id', 'dept_parent_id', 'dept_id', 'name'];



    public function parent(): BelongsTo
    {
        return $this->belongsTo(self::class, 'dept_parent_id', 'dept_id');
    }

    public function ding(): BelongsTo
    {
        return $this->belongsTo(Ding::class);
    }

    //员工
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class, 'dept_id', 'dept_id');
    }
}
